home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-18 | 7.5 KB | 162 lines | [TEXT/CWIE] |
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** Header for common routines for dispatching for a sound component
- **
- ** by Mark Cookson, Apple Developer Technical Support
- **
- ** File: ComponentDispatch.h
- **
- ** Copyright ©1996 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "Apple Sample
- ** Code" after having made changes. If you're going to re-distribute the
- ** source, we require that you make it clear in the source that the code
- ** was descended from Apple Sample Code, but that you've made changes.
- */
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Sound Component Function Prototypes
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // component stuff
-
- static pascal ComponentResult __SoundComponentOpen(void *unused1, ComponentInstance self);
- static pascal ComponentResult __SoundComponentClose(SoundComponentGlobalsPtr globals, ComponentInstance self);
- static pascal ComponentResult __SoundComponentRegister(SoundComponentGlobalsPtr globals);
- static pascal ComponentResult __SoundComponentCanDo(void *unused1, short selector);
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // basic stuff
-
- static pascal ComponentResult __SoundComponentSetSource(SoundComponentGlobalsPtr globals, SoundSource sourceID, ComponentInstance source);
- static pascal ComponentResult __SoundComponentGetSourceData(SoundComponentGlobalsPtr globals, SoundComponentDataPtr *sourceData);
- static pascal ComponentResult __SoundComponentSetOutput(SoundComponentGlobalsPtr globals, SoundComponentDataPtr requested, SoundComponentDataPtr *actual);
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // info methods
-
- static pascal ComponentResult __SoundComponentGetInfo(SoundComponentGlobalsPtr globals, SoundSource sourceID, OSType selector, void *infoPtr);
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // control methods
-
- static pascal ComponentResult __SoundComponentStopSource(SoundComponentGlobalsPtr globals, short count, SoundSource *sources);
- static pascal ComponentResult __SoundComponentPlaySourceBuffer(SoundComponentGlobalsPtr globals, SoundSource sourceID, SoundParamBlockPtr pb, long actions);
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // types
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- #if GENERATINGPOWERPC
-
- // These structs are use in PowerMac builds to cast the
- // ComponentParameters passed into our component's entry point.
-
- enum {
- uppSoundComponentEntryPointProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentParameters *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void *)))
- };
-
- // These are used to create the routine descriptor to call each function.
-
- enum {
- upp__SoundComponentOpenProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ComponentInstance)))
- };
-
- enum {
- upp__SoundComponentCloseProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ComponentInstance)))
- };
-
- enum {
- upp__SoundComponentRegisterProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- };
-
- enum {
- upp__SoundComponentSetSourceProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(ComponentInstance)))
- };
-
- enum {
- upp__SoundComponentGetSourceDataProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundComponentDataPtr)))
- };
-
- enum {
- upp__SoundComponentSetOutputProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundComponentDataPtr)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(SoundComponentDataPtr)))
- };
-
- enum {
- upp__SoundComponentGetInfoProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSType)))
- | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void *)))
- };
-
- enum {
- upp__SoundComponentStopSourceProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(SoundSource)))
- };
-
- enum {
- upp__SoundComponentPlaySourceBufferProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(SoundParamBlockPtr)))
- | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
- };
-
- #define CallComponentFunctionWithStorageUniv(storage, params, funcName) \
- CallComponentFunctionWithStorage(storage, params, &funcName##RD)
- #define CallComponentFunctionUniv(params, funcName) \
- CallComponentFunction(params, &funcName##RD)
- #define INSTANTIATE_ROUTINE_DESCRIPTOR(funcName) RoutineDescriptor funcName##RD = \
- BUILD_ROUTINE_DESCRIPTOR (upp##funcName##ProcInfo, funcName)
-
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentRegister);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentClose);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentOpen);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentSetSource);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentGetSourceData);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentSetOutput);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentGetInfo);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentStopSource);
- INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentPlaySourceBuffer);
-
- #else //GENERATING68K
-
- #define CallComponentFunctionWithStorageUniv(storage, params, funcName) \
- CallComponentFunctionWithStorage(storage, params, (ComponentFunctionUPP)funcName)
- #define CallComponentFunctionUniv(params, funcName) \
- CallComponentFunction(params, (ComponentFunctionUPP)funcName)
- #endif
-